/*
 * XML Type:  datastreamType
 * Namespace: info:fedora/fedora-system:def/foxml#
 * Java type: fedora.fedoraSystemDef.foxml.DatastreamType
 *
 * Automatically generated - do not modify.
 */
package fedora.fedoraSystemDef.foxml.impl;
/**
 * An XML datastreamType(@info:fedora/fedora-system:def/foxml#).
 *
 * This is a complex type.
 */
public class DatastreamTypeImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements fedora.fedoraSystemDef.foxml.DatastreamType
{
    private static final long serialVersionUID = 1L;
    
    public DatastreamTypeImpl(org.apache.xmlbeans.SchemaType sType)
    {
        super(sType);
    }
    
    private static final javax.xml.namespace.QName DATASTREAMVERSION$0 = 
        new javax.xml.namespace.QName("info:fedora/fedora-system:def/foxml#", "datastreamVersion");
    private static final javax.xml.namespace.QName ID$2 = 
        new javax.xml.namespace.QName("", "ID");
    private static final javax.xml.namespace.QName CONTROLGROUP$4 = 
        new javax.xml.namespace.QName("", "CONTROL_GROUP");
    private static final javax.xml.namespace.QName FEDORAURI$6 = 
        new javax.xml.namespace.QName("", "FEDORA_URI");
    private static final javax.xml.namespace.QName STATE$8 = 
        new javax.xml.namespace.QName("", "STATE");
    private static final javax.xml.namespace.QName VERSIONABLE$10 = 
        new javax.xml.namespace.QName("", "VERSIONABLE");
    
    
    /**
     * Gets array of all "datastreamVersion" elements
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
	public fedora.fedoraSystemDef.foxml.DatastreamVersionType[] getDatastreamVersionArray()
    {
        synchronized (monitor())
        {
            check_orphaned();
            java.util.List targetList = new java.util.ArrayList();
            get_store().find_all_element_users(DATASTREAMVERSION$0, targetList);
            fedora.fedoraSystemDef.foxml.DatastreamVersionType[] result = new fedora.fedoraSystemDef.foxml.DatastreamVersionType[targetList.size()];
            targetList.toArray(result);
            return result;
        }
    }
    
    /**
     * Gets ith "datastreamVersion" element
     */
    public fedora.fedoraSystemDef.foxml.DatastreamVersionType getDatastreamVersionArray(int i)
    {
        synchronized (monitor())
        {
            check_orphaned();
            fedora.fedoraSystemDef.foxml.DatastreamVersionType target = null;
            target = (fedora.fedoraSystemDef.foxml.DatastreamVersionType)get_store().find_element_user(DATASTREAMVERSION$0, i);
            if (target == null)
            {
                throw new IndexOutOfBoundsException();
            }
            return target;
        }
    }
    
    /**
     * Returns number of "datastreamVersion" element
     */
    public int sizeOfDatastreamVersionArray()
    {
        synchronized (monitor())
        {
            check_orphaned();
            return get_store().count_elements(DATASTREAMVERSION$0);
        }
    }
    
    /**
     * Sets array of all "datastreamVersion" element
     */
    public void setDatastreamVersionArray(fedora.fedoraSystemDef.foxml.DatastreamVersionType[] datastreamVersionArray)
    {
        synchronized (monitor())
        {
            check_orphaned();
            arraySetterHelper(datastreamVersionArray, DATASTREAMVERSION$0);
        }
    }
    
    /**
     * Sets ith "datastreamVersion" element
     */
    public void setDatastreamVersionArray(int i, fedora.fedoraSystemDef.foxml.DatastreamVersionType datastreamVersion)
    {
        synchronized (monitor())
        {
            check_orphaned();
            fedora.fedoraSystemDef.foxml.DatastreamVersionType target = null;
            target = (fedora.fedoraSystemDef.foxml.DatastreamVersionType)get_store().find_element_user(DATASTREAMVERSION$0, i);
            if (target == null)
            {
                throw new IndexOutOfBoundsException();
            }
            target.set(datastreamVersion);
        }
    }
    
    /**
     * Inserts and returns a new empty value (as xml) as the ith "datastreamVersion" element
     */
    public fedora.fedoraSystemDef.foxml.DatastreamVersionType insertNewDatastreamVersion(int i)
    {
        synchronized (monitor())
        {
            check_orphaned();
            fedora.fedoraSystemDef.foxml.DatastreamVersionType target = null;
            target = (fedora.fedoraSystemDef.foxml.DatastreamVersionType)get_store().insert_element_user(DATASTREAMVERSION$0, i);
            return target;
        }
    }
    
    /**
     * Appends and returns a new empty value (as xml) as the last "datastreamVersion" element
     */
    public fedora.fedoraSystemDef.foxml.DatastreamVersionType addNewDatastreamVersion()
    {
        synchronized (monitor())
        {
            check_orphaned();
            fedora.fedoraSystemDef.foxml.DatastreamVersionType target = null;
            target = (fedora.fedoraSystemDef.foxml.DatastreamVersionType)get_store().add_element_user(DATASTREAMVERSION$0);
            return target;
        }
    }
    
    /**
     * Removes the ith "datastreamVersion" element
     */
    public void removeDatastreamVersion(int i)
    {
        synchronized (monitor())
        {
            check_orphaned();
            get_store().remove_element(DATASTREAMVERSION$0, i);
        }
    }
    
    /**
     * Gets the "ID" attribute
     */
    public java.lang.String getID()
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.apache.xmlbeans.SimpleValue target = null;
            target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(ID$2);
            if (target == null)
            {
                return null;
            }
            return target.getStringValue();
        }
    }
    
    /**
     * Gets (as xml) the "ID" attribute
     */
    public fedora.fedoraSystemDef.foxml.IdType xgetID()
    {
        synchronized (monitor())
        {
            check_orphaned();
            fedora.fedoraSystemDef.foxml.IdType target = null;
            target = (fedora.fedoraSystemDef.foxml.IdType)get_store().find_attribute_user(ID$2);
            return target;
        }
    }
    
    /**
     * Sets the "ID" attribute
     */
    public void setID(java.lang.String id)
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.apache.xmlbeans.SimpleValue target = null;
            target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(ID$2);
            if (target == null)
            {
                target = (org.apache.xmlbeans.SimpleValue)get_store().add_attribute_user(ID$2);
            }
            target.setStringValue(id);
        }
    }
    
    /**
     * Sets (as xml) the "ID" attribute
     */
    public void xsetID(fedora.fedoraSystemDef.foxml.IdType id)
    {
        synchronized (monitor())
        {
            check_orphaned();
            fedora.fedoraSystemDef.foxml.IdType target = null;
            target = (fedora.fedoraSystemDef.foxml.IdType)get_store().find_attribute_user(ID$2);
            if (target == null)
            {
                target = (fedora.fedoraSystemDef.foxml.IdType)get_store().add_attribute_user(ID$2);
            }
            target.set(id);
        }
    }
    
    /**
     * Gets the "CONTROL_GROUP" attribute
     */
    public fedora.fedoraSystemDef.foxml.DatastreamType.CONTROLGROUP.Enum getCONTROLGROUP()
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.apache.xmlbeans.SimpleValue target = null;
            target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(CONTROLGROUP$4);
            if (target == null)
            {
                return null;
            }
            return (fedora.fedoraSystemDef.foxml.DatastreamType.CONTROLGROUP.Enum)target.getEnumValue();
        }
    }
    
    /**
     * Gets (as xml) the "CONTROL_GROUP" attribute
     */
    public fedora.fedoraSystemDef.foxml.DatastreamType.CONTROLGROUP xgetCONTROLGROUP()
    {
        synchronized (monitor())
        {
            check_orphaned();
            fedora.fedoraSystemDef.foxml.DatastreamType.CONTROLGROUP target = null;
            target = (fedora.fedoraSystemDef.foxml.DatastreamType.CONTROLGROUP)get_store().find_attribute_user(CONTROLGROUP$4);
            return target;
        }
    }
    
    /**
     * Sets the "CONTROL_GROUP" attribute
     */
    public void setCONTROLGROUP(fedora.fedoraSystemDef.foxml.DatastreamType.CONTROLGROUP.Enum controlgroup)
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.apache.xmlbeans.SimpleValue target = null;
            target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(CONTROLGROUP$4);
            if (target == null)
            {
                target = (org.apache.xmlbeans.SimpleValue)get_store().add_attribute_user(CONTROLGROUP$4);
            }
            target.setEnumValue(controlgroup);
        }
    }
    
    /**
     * Sets (as xml) the "CONTROL_GROUP" attribute
     */
    public void xsetCONTROLGROUP(fedora.fedoraSystemDef.foxml.DatastreamType.CONTROLGROUP controlgroup)
    {
        synchronized (monitor())
        {
            check_orphaned();
            fedora.fedoraSystemDef.foxml.DatastreamType.CONTROLGROUP target = null;
            target = (fedora.fedoraSystemDef.foxml.DatastreamType.CONTROLGROUP)get_store().find_attribute_user(CONTROLGROUP$4);
            if (target == null)
            {
                target = (fedora.fedoraSystemDef.foxml.DatastreamType.CONTROLGROUP)get_store().add_attribute_user(CONTROLGROUP$4);
            }
            target.set(controlgroup);
        }
    }
    
    /**
     * Gets the "FEDORA_URI" attribute
     */
    public java.lang.String getFEDORAURI()
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.apache.xmlbeans.SimpleValue target = null;
            target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(FEDORAURI$6);
            if (target == null)
            {
                return null;
            }
            return target.getStringValue();
        }
    }
    
    /**
     * Gets (as xml) the "FEDORA_URI" attribute
     */
    public org.apache.xmlbeans.XmlAnyURI xgetFEDORAURI()
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.apache.xmlbeans.XmlAnyURI target = null;
            target = (org.apache.xmlbeans.XmlAnyURI)get_store().find_attribute_user(FEDORAURI$6);
            return target;
        }
    }
    
    /**
     * True if has "FEDORA_URI" attribute
     */
    public boolean isSetFEDORAURI()
    {
        synchronized (monitor())
        {
            check_orphaned();
            return get_store().find_attribute_user(FEDORAURI$6) != null;
        }
    }
    
    /**
     * Sets the "FEDORA_URI" attribute
     */
    public void setFEDORAURI(java.lang.String fedorauri)
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.apache.xmlbeans.SimpleValue target = null;
            target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(FEDORAURI$6);
            if (target == null)
            {
                target = (org.apache.xmlbeans.SimpleValue)get_store().add_attribute_user(FEDORAURI$6);
            }
            target.setStringValue(fedorauri);
        }
    }
    
    /**
     * Sets (as xml) the "FEDORA_URI" attribute
     */
    public void xsetFEDORAURI(org.apache.xmlbeans.XmlAnyURI fedorauri)
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.apache.xmlbeans.XmlAnyURI target = null;
            target = (org.apache.xmlbeans.XmlAnyURI)get_store().find_attribute_user(FEDORAURI$6);
            if (target == null)
            {
                target = (org.apache.xmlbeans.XmlAnyURI)get_store().add_attribute_user(FEDORAURI$6);
            }
            target.set(fedorauri);
        }
    }
    
    /**
     * Unsets the "FEDORA_URI" attribute
     */
    public void unsetFEDORAURI()
    {
        synchronized (monitor())
        {
            check_orphaned();
            get_store().remove_attribute(FEDORAURI$6);
        }
    }
    
    /**
     * Gets the "STATE" attribute
     */
    public fedora.fedoraSystemDef.foxml.StateType.Enum getSTATE()
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.apache.xmlbeans.SimpleValue target = null;
            target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(STATE$8);
            if (target == null)
            {
                return null;
            }
            return (fedora.fedoraSystemDef.foxml.StateType.Enum)target.getEnumValue();
        }
    }
    
    /**
     * Gets (as xml) the "STATE" attribute
     */
    public fedora.fedoraSystemDef.foxml.StateType xgetSTATE()
    {
        synchronized (monitor())
        {
            check_orphaned();
            fedora.fedoraSystemDef.foxml.StateType target = null;
            target = (fedora.fedoraSystemDef.foxml.StateType)get_store().find_attribute_user(STATE$8);
            return target;
        }
    }
    
    /**
     * True if has "STATE" attribute
     */
    public boolean isSetSTATE()
    {
        synchronized (monitor())
        {
            check_orphaned();
            return get_store().find_attribute_user(STATE$8) != null;
        }
    }
    
    /**
     * Sets the "STATE" attribute
     */
    public void setSTATE(fedora.fedoraSystemDef.foxml.StateType.Enum state)
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.apache.xmlbeans.SimpleValue target = null;
            target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(STATE$8);
            if (target == null)
            {
                target = (org.apache.xmlbeans.SimpleValue)get_store().add_attribute_user(STATE$8);
            }
            target.setEnumValue(state);
        }
    }
    
    /**
     * Sets (as xml) the "STATE" attribute
     */
    public void xsetSTATE(fedora.fedoraSystemDef.foxml.StateType state)
    {
        synchronized (monitor())
        {
            check_orphaned();
            fedora.fedoraSystemDef.foxml.StateType target = null;
            target = (fedora.fedoraSystemDef.foxml.StateType)get_store().find_attribute_user(STATE$8);
            if (target == null)
            {
                target = (fedora.fedoraSystemDef.foxml.StateType)get_store().add_attribute_user(STATE$8);
            }
            target.set(state);
        }
    }
    
    /**
     * Unsets the "STATE" attribute
     */
    public void unsetSTATE()
    {
        synchronized (monitor())
        {
            check_orphaned();
            get_store().remove_attribute(STATE$8);
        }
    }
    
    /**
     * Gets the "VERSIONABLE" attribute
     */
    public boolean getVERSIONABLE()
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.apache.xmlbeans.SimpleValue target = null;
            target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(VERSIONABLE$10);
            if (target == null)
            {
                target = (org.apache.xmlbeans.SimpleValue)get_default_attribute_value(VERSIONABLE$10);
            }
            if (target == null)
            {
                return false;
            }
            return target.getBooleanValue();
        }
    }
    
    /**
     * Gets (as xml) the "VERSIONABLE" attribute
     */
    public org.apache.xmlbeans.XmlBoolean xgetVERSIONABLE()
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.apache.xmlbeans.XmlBoolean target = null;
            target = (org.apache.xmlbeans.XmlBoolean)get_store().find_attribute_user(VERSIONABLE$10);
            if (target == null)
            {
                target = (org.apache.xmlbeans.XmlBoolean)get_default_attribute_value(VERSIONABLE$10);
            }
            return target;
        }
    }
    
    /**
     * True if has "VERSIONABLE" attribute
     */
    public boolean isSetVERSIONABLE()
    {
        synchronized (monitor())
        {
            check_orphaned();
            return get_store().find_attribute_user(VERSIONABLE$10) != null;
        }
    }
    
    /**
     * Sets the "VERSIONABLE" attribute
     */
    public void setVERSIONABLE(boolean versionable)
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.apache.xmlbeans.SimpleValue target = null;
            target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(VERSIONABLE$10);
            if (target == null)
            {
                target = (org.apache.xmlbeans.SimpleValue)get_store().add_attribute_user(VERSIONABLE$10);
            }
            target.setBooleanValue(versionable);
        }
    }
    
    /**
     * Sets (as xml) the "VERSIONABLE" attribute
     */
    public void xsetVERSIONABLE(org.apache.xmlbeans.XmlBoolean versionable)
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.apache.xmlbeans.XmlBoolean target = null;
            target = (org.apache.xmlbeans.XmlBoolean)get_store().find_attribute_user(VERSIONABLE$10);
            if (target == null)
            {
                target = (org.apache.xmlbeans.XmlBoolean)get_store().add_attribute_user(VERSIONABLE$10);
            }
            target.set(versionable);
        }
    }
    
    /**
     * Unsets the "VERSIONABLE" attribute
     */
    public void unsetVERSIONABLE()
    {
        synchronized (monitor())
        {
            check_orphaned();
            get_store().remove_attribute(VERSIONABLE$10);
        }
    }
    /**
     * An XML CONTROL_GROUP(@).
     *
     * This is an atomic type that is a restriction of fedora.fedoraSystemDef.foxml.DatastreamType$CONTROLGROUP.
     */
    public static class CONTROLGROUPImpl extends org.apache.xmlbeans.impl.values.JavaStringEnumerationHolderEx implements fedora.fedoraSystemDef.foxml.DatastreamType.CONTROLGROUP
    {
        private static final long serialVersionUID = 1L;
        
        public CONTROLGROUPImpl(org.apache.xmlbeans.SchemaType sType)
        {
            super(sType, false);
        }
        
        protected CONTROLGROUPImpl(org.apache.xmlbeans.SchemaType sType, boolean b)
        {
            super(sType, b);
        }
    }
}
